const todolist=require('../models/todolist.js');
const querystring = require("querystring");
const getTodolist=async (ctx)=>{
	const id=ctx.params.id;
	const result=await todolist.getIodolistById(id);
	ctx.body=result
}

const createTodolist=async(ctx)=>{
	const data=ctx.request.body;
	const result=await todolist.createTodolist(data);
	ctx.body={
		success:true
	}
}
const deletTodolist=async function(ctx){
	const id=ctx.params.id
	const user_id=ctx.params.userId
	const result=await todolist.deletTodolist(id, user_id);
	ctx.body={
		success:true
	}
} 
const updateTodolist=async function(ctx){
	const id=ctx.request.body.id;
	const user_id=ctx.request.body.userId;
	let status=ctx.request.body.status;
	
	status=='0'?status=1:status=0
	const result=await todolist.updateTodolist(id,user_id,status);
	ctx.body={
		success:true
	}
}

module.exports={
	getTodolist,
	createTodolist,
	deletTodolist,
	updateTodolist

}